package net.funwoo.pandago.ui.user;

import android.os.Bundle;

import net.funwoo.pandago.Keys;
import net.funwoo.pandago.R;
import net.funwoo.pandago.event.VerifyEvent;
import net.funwoo.pandago.ui.BaseActivity;

import de.greenrobot.event.EventBus;

public class RegisterActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_container, true);
    }

    @Override
    protected void onResume() {
        super.onResume();
        EventBus.getDefault().registerSticky(this);
    }

    @Override
    protected void onStop() {
        super.onStop();
        EventBus.getDefault().unregister(this);
    }

    @Override
    protected void initView() {
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new
                PhoneVerifyFragment()).commit();
    }

    public void onEvent(VerifyEvent event) {
        RegisterFragment registerFragment = new RegisterFragment();
        Bundle bundle = new Bundle();
        bundle.putString(Keys.EXTRA_PHONE, event.phoneNumber);
        registerFragment.setArguments(bundle);
        getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, registerFragment)
                .commit();
    }
}
